let app = getApp()
Component({
    properties: {
          vueId:Number,
          content_type:Number
      },
      data:{
        title: "内容详情",
        courseId: 0,
        courseData: {},
        audioContent: null,
        audioDuration: "00:00",
        audioPlayStatus: !1,
        audioCurrentTime: "00:00",
        audioFinishWidth: 0,
        audioDotMove: !1,
        audioProcessInfo: {},
        parentType: 0,
        videoPlayEnd: !1,
        videoContent: null,
        videoDuration: "00:00",
        videoPlayStatus: !1,
        videoCurrentTime: "00:00",
        videoFinishWidth: 0,
        videoDotMove: !1,
        videoProcessInfo: {},
        videoDurationTime: 0,
        payBtnShow: !0,
        videoAd: null,
        nextContentId: 0,
        moneySign:'¥',
        siteDomain:app.globalData.siteDomain
      },
    lifetimes: {
        attached: function () {
            var that=this
            wx.request({
              url: app.globalData.siteroot,
              data: { 
                do:'Knowledge_getContent',
                content_id:that.data.vueId,
                user_id:wx.getStorageSync('user_id'),
                content_type:that.data.content_type
              },
              success: function(res) {
                 that.setData({
                  courseData:res.data.data
                 })
                 var sharedata=[];
                 var share_title=res.data.data.name
                 if(typeof(res.data.data.share_title)!='undefined'){
                   if(res.data.data.share_title!=''&&res.data.data.share_title!=null){
                      share_title=res.data.data.share_title
                   }
                 }
                 sharedata['title']=share_title,
                 sharedata['cover']=typeof(res.data.data.share_cover)!='undefined'?res.data.data.share_cover:'',
                 that.triggerEvent('changeshare',sharedata) 
              }
            })
       }
      },
    methods: {
      lookzhuan:function(){
        wx.navigateBack({
          delta: 1,
          success: function() {
              console.log('成功！')
          }
        })
      },
      nowbuy:function(){
        var order=[];
        var cacheParams={
          id:this.data.courseData.goods_id,
          goods_id:this.data.courseData.goods_id,
          title:encodeURIComponent(this.data.courseData.name),
          count:1,
          num:1,
          goods_name:this.data.courseData.name,
          pic:this.data.courseData.image,
          image:encodeURIComponent(this.data.courseData.image), 
          skuId:0,
          sku_id:0,
          template_id:0,
          cate:[], 
          shoppingId:0, 
          price:this.data.courseData.price,
          hideCount:true
        }
        order.push(cacheParams)
        wx.setStorageSync('confirmorder',order)
        wx.navigateTo({ 
          url: '/yb_shopv2/native/all/index?type=confirm_order&params='+JSON.stringify([cacheParams ])+"&order_type=1&good_type=3&page_type=course",
       })
      }
    }
});
